package com.zzhua.quartz;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.annotation.Resource;

@Configuration
public class MySchedulerListener {
      
    @Resource
    MyJobFactory myJobFactory;

      
    @Bean(name ="schedulerFactoryBean")
    public SchedulerFactoryBean schedulerFactory() {
        SchedulerFactoryBean bean = new SchedulerFactoryBean();
        bean.setJobFactory(myJobFactory); // 把下面这个JobFactory注入给了SchedulerFactoryBean
        
        // 设置quartz.properties配置文件
        bean.setConfigLocation(new ClassPathResource("quartz.properties"));
        return bean;  
    }  
  
}  